package com.cdtye.itps.cms.dao.datasysn;

import com.cdtye.common.kafkacore.model.dto.KfkBaseDto;
import com.cdtye.common.webcore.enums.YesNoEnum;
import com.cdtye.common.webcore.util.ObjectUtil;
import com.cdtye.itps.cms.dao.origindata.entity.JcjcDetectC1Job;
import com.cdtye.itps.cms.dao.origindata.entity.JcjcDetectC2Job;
import com.cdtye.itps.cms.dao.origindata.entity.JcjcDetectC4Job;
import com.cdtye.itps.cms.util.DateUtils;
import com.cdtye.itps.cms.dao.enums.DelFlagEnum;
import com.cdtye.itps.models.base.model.attr.basic.DirectionAttr;
import com.cdtye.itps.models.base.model.attr.basic.LineAttr;
import com.cdtye.itps.models.base.model.attr.basic.SiteAttr;
import com.cdtye.itps.models.base.model.entity.detect.JcwDetectC1Job;
import com.cdtye.itps.models.base.model.entity.detect.JcwDetectC2Job;
import com.cdtye.itps.models.base.model.entity.detect.JcwDetectC4Job;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@ApiModel(value = "124C检测作业")
@Data
@Accessors(chain = true)
public class C124DetectJob extends KfkBaseDto {
    @ApiModelProperty(value = "各段原始数据文件包Id")
    private String packageId;
    //C类型（1、2、4）
    @ApiModelProperty(value = "类型")
    private String type;
    @ApiModelProperty(value = "路局编码")
    private String railwayCode;
    @ApiModelProperty(value = "路局名称")
    private String railwayName;
    @ApiModelProperty(value = "供电段编码")
    private String powerSupplySectionCode;
    @ApiModelProperty(value = "供电段名称")
    private String powerSupplySectionName;
    @ApiModelProperty(value = "装置厂商编码(唐源-TY；国铁电器-GTDQ)")
    private String firmCode;
    @ApiModelProperty(value = "装置厂商名称")
    private String firmName;
    @ApiModelProperty(value = "线路名称")
    private String lineName;
    @ApiModelProperty(value = "线路编码")
    private String lineCode;
    //(上行 2； 下行 1； 单线 0)
    @ApiModelProperty(value = "行别")
    private String lineDirect;
    @ApiModelProperty(value = "起始站")
    private String startStation;
    @ApiModelProperty(value = "终到站")
    private String endStation;
    @ApiModelProperty(value = "检测日期")
    private Long detectionDate;
    @ApiModelProperty(value = "上传日期")
    private Long uploadDate;
    @ApiModelProperty(value = "上传人")
    private String uploader;

    public Map covEntity() {
        Map rsMap = new HashMap();
        if("1".equals(this.type)){
            JcjcDetectC1Job jcjcDetectC1Job = ObjectUtil.copyProperties(this, JcjcDetectC1Job.class);
            JcwDetectC1Job model = ObjectUtil.copyProperties(this, JcwDetectC1Job.class);
            model.setLineAttr(new LineAttr().setLineCode(this.lineCode).setLineName(this.lineName));
            model.setBeginSiteAttr(new SiteAttr().setLineSiteCode(this.startStation).setSiteName(this.startStation));
            model.setEndSiteAttr(new SiteAttr().setLineSiteCode(this.endStation).setSiteName(this.endStation));
            model.setDirectionAttr(new DirectionAttr().setDirectionCode(this.lineDirect).setDirectionName(this.lineDirect));

            //model.setDetectDeviceAttr(new DetectDeviceAttr().setDetectDeviceId(this.detectDeviceId).setDetectDeviceCode(this.detectDeviceCode).setDetectDeviceName(detectDeviceName));
            model.setId(this.packageId);
            model.setStatus(1);
            model.setDelFlag(0);
            model.setBureau(this.railwayName);
            model.setCreateTime(new Date());
            model.setUpdateTime(new Date());
            if(this.detectionDate != null){
                model.setDetectDate(DateUtils.longToDate(this.detectionDate));
            }
            model.setIndexFlag(YesNoEnum.NO.getCode());
            model.setTyIndexFlag(YesNoEnum.NO.getCode());
            model.setBureauCode(this.railwayCode);
            model.setPowerSupplySectionCode(this.powerSupplySectionCode);
            model.setPowerSupplySectionName(this.powerSupplySectionName);
            model.setFirmCode(this.firmCode);
            model.setFirmName(this.firmName);
            model.setUploadDate(DateUtils.longToDate(this.uploadDate));
            model.setUploader(this.uploader);
            //----------------
            jcjcDetectC1Job.setStartSiteName(this.startStation);
            jcjcDetectC1Job.setEndSiteName(this.endStation);
            jcjcDetectC1Job.setDetectJobId(this.packageId);
            jcjcDetectC1Job.setStatus(1);
            jcjcDetectC1Job.setDelFlag(DelFlagEnum.NO);
            jcjcDetectC1Job.setBureau(this.railwayName);
            jcjcDetectC1Job.setUpdateDatetime(DateUtils.longToDate(this.uploadDate));
            if(this.detectionDate != null){
                jcjcDetectC1Job.setDetectDate(DateUtils.longToDate(this.detectionDate));
            }
            jcjcDetectC1Job.setIndexFlag(YesNoEnum.NO.getCode());
            jcjcDetectC1Job.setTyIndexFlag(YesNoEnum.NO.getCode());
            rsMap.put("model", model);
            rsMap.put("detectCxJob", jcjcDetectC1Job);
        }else if("2".equals(this.type)){
            JcjcDetectC2Job jcjcDetectC2Job = ObjectUtil.copyProperties(this, JcjcDetectC2Job.class);
            JcwDetectC2Job model = ObjectUtil.copyProperties(this, JcwDetectC2Job.class);
            model.setLineAttr(new LineAttr().setLineCode(this.lineCode).setLineName(this.lineName));
            model.setBeginSiteAttr(new SiteAttr().setLineSiteCode(this.startStation).setSiteName(this.startStation));
            model.setEndSiteAttr(new SiteAttr().setLineSiteCode(this.endStation).setSiteName(this.endStation));
            model.setDirectionAttr(new DirectionAttr().setDirectionCode(this.lineDirect).setDirectionName(this.lineDirect));
            //model.setBeginPillarAttr(new PillarAttr().setPillarNum(this.startPillarNo));
            //model.setEndPillarAttr(new PillarAttr().setPillarNum(this.endPillarNo));
            //model.setDetectDeviceAttr(new DetectDeviceAttr().setDetectDeviceId(this.detectDeviceId).setDetectDeviceCode(this.detectDeviceCode).setDetectDeviceName(detectDeviceName));
            model.setId(this.packageId);
            if(this.detectionDate != null){
                model.setDetectDate(DateUtils.longToDate(this.detectionDate));
            }
            //model.setBeginRecordTime(this.startRecordTime);
            //model.setEndRecordTime(this.endRecordTime);
            /*if (StringUtils.isNotBlank(this.startKm)) {
                if (this.startKm.contains(WebConstants.CHAR_K)) {
                    model.setBeginMark(RoadMarkUtil.covRoadMark(this.startKm));
                } else {
                    model.setBeginMark(Double.valueOf(this.startKm));
                }
            }
            if (StringUtils.isNotBlank(this.endKm)) {
                if (this.endKm.contains(WebConstants.CHAR_K)) {
                    model.setEndMark(RoadMarkUtil.covRoadMark(this.endKm));
                } else {
                    model.setEndMark(Double.valueOf(this.endKm));
                }
            }*/
            /*
            model.setPanoraMicPixel(this.panoraMicpixel);
            model.setPartPixel(this.partPixel);
            model.setDataPath(this.dataPath);
            model.setPacketName(this.packetName);
            model.setInfoFileName(this.infoFileName);
            model.setIndexFileName(this.indexFileName);
            model.setReadInfoFile(this.readInfoFile == null ? null : this.readInfoFile ? "1" : "0");
            model.setReadIndexFile(this.readIndexFile == null ? null : this.readIndexFile ? 1 : 0);
            model.setIsVideo(this.isVideo == null ? null : this.isVideo ? 1 : 0);
            model.setVideoPathList(this.videoPathAttr);
            */
            model.setBureau(this.railwayName);
            model.setBureauCode(this.railwayCode);
            model.setPowerSupplySectionCode(this.powerSupplySectionCode);
            model.setPowerSupplySectionName(this.powerSupplySectionName);
            model.setFirmCode(this.firmCode);
            model.setFirmName(this.firmName);
            model.setUploadDate(DateUtils.longToDate(this.uploadDate));
            model.setUploader(this.uploader);
            model.setStatus(YesNoEnum.YES.getCode());
            model.setDelFlag(YesNoEnum.NO.getCode());
            model.setCreateTime(new Date());
            model.setUpdateTime(new Date());
            //model.setPackageSize(this.packageSize);
            model.setIndexFlag(YesNoEnum.NO.getCode());
            model.setTyIndexFlag(YesNoEnum.NO.getCode());
            //--------------------------------------------------------
            jcjcDetectC2Job.setDetectJobId(this.packageId);
            if(this.detectionDate != null){
                jcjcDetectC2Job.setDetectDate(DateUtils.longToDate(this.detectionDate));
            }
            jcjcDetectC2Job.setStatus(YesNoEnum.YES.getCode());
            jcjcDetectC2Job.setDelFlag(DelFlagEnum.NO);
            jcjcDetectC2Job.setUpdateDatetime(DateUtils.longToDate(this.uploadDate));
            jcjcDetectC2Job.setIndexFlag(YesNoEnum.NO.getCode());
            jcjcDetectC2Job.setTyIndexFlag(YesNoEnum.NO.getCode());
            rsMap.put("model", model);
            rsMap.put("detectCxJob", jcjcDetectC2Job);
        }else if("4".equals(this.type)){
            JcjcDetectC4Job jcjcDetectC4Job = ObjectUtil.copyProperties(this, JcjcDetectC4Job.class);
            JcwDetectC4Job model = new JcwDetectC4Job();
            model.setLineAttr(new LineAttr().setLineCode(this.lineCode).setLineName(this.lineName));
            model.setBeginSiteAttr(new SiteAttr().setLineSiteCode(this.startStation).setSiteName(this.startStation));
            model.setEndSiteAttr(new SiteAttr().setLineSiteCode(this.endStation).setSiteName(this.endStation));
            model.setDirectionAttr(new DirectionAttr().setDirectionCode(this.lineDirect).setDirectionName(this.lineDirect));
            //model.setDetectDeviceAttr(new DetectDeviceAttr().setDetectDeviceId(this.detectDeviceId).setDetectDeviceCode(this.detectDeviceCode).setDetectDeviceName(detectDeviceName));
            //model.setStartPillarAttr(new PillarAttr().setPillarNum(this.startPillarNo));
            //model.setEndPillarAttr(new PillarAttr().setPillarNum(this.endPillarNo));
            model.setId(this.packageId);
            //model.setBeginRecordTime(this.startRecordTime);
            //model.setEndRecordTime(this.endRecordTime);
            /*if (StringUtils.isNotBlank(this.startKm)) {
                if (this.startKm.contains(WebConstants.CHAR_K)) {
                    model.setBeginMark(RoadMarkUtil.covRoadMark(this.startKm));
                } else {
                    model.setBeginMark(Double.valueOf(this.startKm));
                }
            }
            if (StringUtils.isNotBlank(this.endKm)) {
                if (this.endKm.contains(WebConstants.CHAR_K)) {
                    model.setEndMark(RoadMarkUtil.covRoadMark(this.endKm));
                } else {
                    model.setEndMark(Double.valueOf(this.endKm));
                }
            }*/
            if(this.detectionDate != null){
                model.setDetectDate(DateUtils.longToDate(this.detectionDate));
            }
            /*
            model.setCamNum(this.cameraNumber);
            model.setSupCamNum(this.supportCameraNumber);
            model.setDroCamNum(this.droppersCameraNumber);
            model.setAppEndCamNum(this.appendCameraNumber);
            model.setDavitCamNum(this.davitCameraNumber);
            model.setDataPath(this.dataPath);
            model.setPacketName(this.packetName);
            model.setInfoFileName(this.infoFileName);
            model.setReadInfoFile(this.readInfoFile == null ? null : this.readInfoFile ? 1 : 0);
            model.setReadGeometry(this.readGeometry == null ? null : this.readGeometry ? 1 : 0);
            model.setReadPilIar(this.readPillarInfo == null ? null : this.readPillarInfo ? 1 : 0);
            model.setReadIndexFile(this.readIndexFile == null ? null : this.readIndexFile ? 1 : 0);
            model.setPackageSize(this.packageSize);
            */
            model.setBureau(this.railwayName);
            model.setBureauCode(this.railwayCode);
            model.setPowerSupplySectionCode(this.powerSupplySectionCode);
            model.setPowerSupplySectionName(this.powerSupplySectionName);
            model.setFirmCode(this.firmCode);
            model.setFirmName(this.firmName);
            model.setUploadDate(DateUtils.longToDate(this.uploadDate));
            model.setUploader(this.uploader);
            model.setStatus(YesNoEnum.YES.getCode());
            model.setDelFlag(YesNoEnum.NO.getCode());
            model.setCreateTime(new Date());
            model.setUpdateTime(new Date());
            model.setIndexFlag(YesNoEnum.NO.getCode());
            model.setTyIndexFlag(YesNoEnum.NO.getCode());
            //model.setDetectMileage(this.detectMileage);
            //----------------------------
            jcjcDetectC4Job.setDetectJobId(this.packageId);
            if(this.detectionDate != null){
                jcjcDetectC4Job.setDetectDate(DateUtils.longToDate(this.detectionDate));
            }
            jcjcDetectC4Job.setStatus(YesNoEnum.YES.getCode());
            jcjcDetectC4Job.setDelFlag(DelFlagEnum.NO);
            jcjcDetectC4Job.setUpdateDatetime(DateUtils.longToDate(this.uploadDate));
            jcjcDetectC4Job.setIndexFlag(YesNoEnum.NO.getCode());
            jcjcDetectC4Job.setTyIndexFlag(YesNoEnum.NO.getCode());
            rsMap.put("model", model);
            rsMap.put("detectCxJob", jcjcDetectC4Job);
        }
        return rsMap;
    }
}
